package org.jeeasy.biz.fastnote.manage.note;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jeeasy.biz.fastnote.modules.member.domain.FnMember;
import org.jeeasy.biz.fastnote.modules.member.service.FnMemberService;
import org.jeeasy.common.core.annotation.dict.DictTranslation;
import org.jeeasy.common.core.base.SimpleCurdController;
import org.jeeasy.common.core.domain.model.QueryPageModel;
import org.jeeasy.common.core.domain.vo.R;
import org.springframework.web.bind.annotation.*;


/**
 * FastNote用户控制器
 *
 * @author AlpsDDJ
 * @description FastNote用户
 * @date 2022/9/11 13:52:05
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@Tag(name = "FastNote笔记")
@RequestMapping("/manage/fn/note")
public class FnNoteController extends SimpleCurdController<FnMemberService, FnMember> {

    @GetMapping
    @DictTranslation
    @Operation(summary = "FastNote用户列表", description = "FastNote用户列表")
    public R<IPage<FnMember>> list(QueryPageModel queryPageModel) {
        return R.ok(super.queryPage(queryPageModel));
    }

    /**
     * @param id
     * @return {@link R<Void>}
     * @author mobie
     * @date 2020/11/21 16:05
     */
    @GetMapping("/{id}")
    @DictTranslation
    @Operation(summary = "根据ID查找FastNote用户", description = "根据ID查找FastNote用户")
    public R<FnMember> info(@PathVariable("id") String id) {
        return R.ok(super.getById(id));
    }

    /**
     * @param entity
     * @return {@link R<Void>}
     * @author mobie
     * @date 2020/11/21 16:03
     */
    @PutMapping
    @Operation(summary = "编辑FastNote用户", description = "编辑FastNote用户")
    public R<Void> edit(@RequestBody FnMember entity) {
        super.update(entity);
        return R.ok();
    }

    /**
     * @param entity
     * @return {@link R<Void>}
     * @author mobie
     * @date 2020/11/21 16:18
     */
    @PostMapping
    @Operation(summary = "添加FastNote用户", description = "添加FastNote用户")
    public R<Void> add(@RequestBody FnMember entity) {
        super.insert(entity);
        return R.ok();
    }

    /**
     * @param id
     * @return {@link R<Void>}
     * @author AlpsDDJ
     * @date 2020/11/21 22:11
     */
    @DeleteMapping("/{id}")
    @Operation(summary = "根据ID删除FastNote用户", description = "根据ID删除FastNote用户")
    public R<Void> remove(@PathVariable("id") String id) {
        super.deleteById(id);
        return R.ok();
    }

    /**
     * @param ids
     * @return {@link R<Void>}
     * @author mobie
     * @date 2020/11/21 16:10
     */
    @DeleteMapping("/batch")
    @Operation(summary = "批量删除FastNote用户", description = "批量删除FastNote用户")
    public R<Void> batchRemove(@RequestParam(name = "ids") String ids) {
        super.batchDelete(ids);
        return R.ok();
    }
}